package com.hejjon.base;

import com.hejjon.bean.ResponseResult;

/**
 * Controller 基类
 */
public class BaseController {


    public <T> ResponseResult<T> success(T data) {
        return new ResponseResult<T>(200, "success", data);
    }


    public <T> ResponseResult<T> error(String msg) {
        return new ResponseResult<>(500, msg, null);
    }


    public <T> ResponseResult<T> ofBool(Boolean b) {
        return b ? success(null) : error("操作失败");
    }

    public <T> ResponseResult<T> ofBool(Boolean b, String msg) {
        return b ? success(null) : error(msg);
    }

}
